package com.zaiteng;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.List;
import java.util.Map;

import anywheresoftware.b4a.BA.ShortName;
import cn.jpush.im.android.api.content.MessageContent;
import cn.jpush.im.android.api.enums.ContentType;
import cn.jpush.im.android.api.enums.ConversationType;
import cn.jpush.im.android.api.model.Conversation;
import cn.jpush.im.android.api.model.GroupInfo;
import cn.jpush.im.android.api.model.Message;

@ShortName("Conversation_im")
public class ConversationWrapper extends Conversation{
	private Conversation conversation;

	public void Initialize(Conversation con1) {
		
		conversation=con1;
	}

	public Conversation getConversation() {
		return conversation;
	}


	public String getId() {
		return conversation.getId();
	}

	public ConversationType getType() {
		return conversation.getType();
	}

	public String getTargetId() {
		return conversation.getTargetId();
	}
	public UserInfoWrapper getUserInfo() {
		try {
			return (UserInfoWrapper) conversation.getTargetInfo();
		} catch (Exception e) {
			// TODO: handle exception
			return null;
		}
		
	}
	public GroupInfo getGroupInfo(){
		try {
			return (GroupInfo) conversation.getTargetInfo();
		} catch (Exception e) {
			// TODO: handle exception
			return null;
		}
		
	}
	public String getTargetAppKey() {
		return conversation.getTargetAppKey();
	}

	public String getLatestText() {
		return conversation.getLatestText();
	}

	public long getLastMsgDate() {
		return conversation.getLastMsgDate();
	}

	public ContentType getLatestType() {
		return conversation.getLatestType();
	}

	public int getUnReadMsgCnt() {
		return conversation.getUnReadMsgCnt();
	}

	public String getTitle() {
		return conversation.getTitle();
	}

	public File getAvatarFile() {
//		if(conversation.getAvatarFile()==null){
//			return "";
//		}
		return conversation.getAvatarFile();
	}
	
	public String getAvatarFileString() {
		if(conversation.getAvatarFile()==null){
			return "";
		}
		return conversation.getAvatarFile().toString();
	}

	public Message getLatestMessage() {
		return conversation.getLatestMessage();
	}

	public String getTargetInfo() {
		return conversation.getTargetInfo().toString();
	}

	public boolean resetUnreadCount(){
		return conversation.resetUnreadCount();
	}

	public Message getMessage(int idx) {
		return conversation.getMessage(idx);
	}

	public anywheresoftware.b4a.objects.collections.List getAllMessageList() {
		List<Message> lstMsg=conversation.getMessagesFromNewest(0,999);
		anywheresoftware.b4a.objects.collections.List lstData=new anywheresoftware.b4a.objects.collections.List();
		for (int i = 0; i < lstMsg.size(); i++) {
			MessageWrapper mw=new MessageWrapper();
			mw.Initialize(lstMsg.get(i));
		}
		return lstData;
	}


	public List getMessagesFromNewest() {
		return conversation.getMessagesFromNewest(0, 0);
	}

	public boolean deleteMessage(int arg0){
		return conversation.deleteMessage(arg0);
	}

	public boolean deleteAllMessage(){
		return conversation.deleteAllMessage();
	}

	public boolean updateMessageExtra(Message arg0, String arg1, String arg2){
		return conversation.updateMessageExtra(arg0, arg1, arg2);
	}

	public boolean updateMessageExtra(Message arg0, String arg1, Number arg2){
		return conversation.updateMessageExtra(arg0, arg1, arg2);
	}

	public boolean updateMessageExtra(Message arg0, String arg1, Boolean arg2){
		return conversation.updateMessageExtra(arg0, arg1, arg2);
	}


	public Message createSendMessage(MessageContent arg0){
		return conversation.createSendMessage(arg0);
	}

	public Message createSendMessage(MessageContent arg0, String arg1){
		return conversation.createSendMessage(arg0, arg1);
	}

	public Message createSendTextMessage(String arg0){
		return conversation.createSendTextMessage(arg0);
	}

	public Message createSendTextMessage(String arg0, String arg1){
		return conversation.createSendTextMessage(arg0, arg1);
	}

	public Message createSendImageMessage(String arg0){
		try {
			return conversation.createSendImageMessage(new File(arg0));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null; 
		}
		
	}

	@Override
	public List<Message> getMessagesFromOldest(int paramInt1, int paramInt2) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Message> getMessagesFromNewest(int paramInt1, int paramInt2) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean updateMessageExtras(Message paramMessage, Map<String, String> paramMap) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public Message createSendImageMessage(File paramFile) throws FileNotFoundException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Message createSendImageMessage(File paramFile, String paramString) throws FileNotFoundException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Message createSendVoiceMessage(File paramFile, int paramInt) throws FileNotFoundException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Message createSendVoiceMessage(File paramFile, int paramInt, String paramString)
			throws FileNotFoundException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Message createSendCustomMessage(Map<? extends String, ? extends String> paramMap) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Message createSendCustomMessage(Map<? extends String, ? extends String> paramMap, String paramString) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Message> getAllMessage() {
		// TODO Auto-generated method stub
		return null;
	}



}
